package com.cf.mapper;

import com.cf.pojo.User;
import com.cf.pojo.UserDto;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author Chengfei
 * @Description
 * @date 2023/6/25
 */
// @Component
public class UserMapperImpl implements UserMapper {
    public UserMapperImpl() {
    }

    @Override
    public UserDto userToUserDto(User user) {
        if (user == null){
            return null;
        }else{
            UserDto userDto = new UserDto();
            user.setId(user.getId());
            user.setName(user.getName());
            user.setCrateTime(user.getCrateTime());
            return userDto;
        }
    }


    @Override
    public List<UserDto> userToUserDtoList(List<User> users) {
        if (users == null){
            return null;
        }else{
            List<UserDto> list = new ArrayList<>(users.size());
            Iterator var3 = users.iterator();

            while (var3.hasNext()){
                User user = (User) var3.next();
                list.add(this.userToUserDto(user));
            }
            return list;
        }
    }
}
